package com.qire.manhua.dialog;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.qire.antsrouter.lifecycleHandler.ActivityManageHandler;
import com.qire.common.support.base.BaseDialog;
import com.qire.manhua.BR;
import com.qire.manhua.R;
import com.qire.manhua.controller.ComicDetailController;
import com.qire.manhua.model.viewModel.impl.ComicDetailViewModel.VipFreeTipsDialogViewModel;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

/**
 * 漫画详情页，会员免费提示对话框：用于漫画详情页
 */
public class VipFreeTipsDialog extends BaseDialog {

    public static VipFreeTipsDialog build(DialogType dialogType) {
        return new VipFreeTipsDialog(ActivityManageHandler.HANDLER.currentActivity(), dialogType);
    }

    public enum DialogType {
        All(R.layout.dialog_vip_free_tips_all),
        Part(R.layout.dialog_vip_free_tips_part);
        int res;
        DialogType(int res){
            this.res = res;
        }
    }

    private final ViewDataBinding viewDataBinder;

    public VipFreeTipsDialog(@NonNull Context context, DialogType dialogType) {
        super(context, R.style.CustomDialog_Translucent);
        this.viewDataBinder = DataBindingUtil.inflate(LayoutInflater.from(context), dialogType.res, null, false);
        viewDataBinder.setVariable(BR.vipFreeTipsDialog, this);
        setContentView(viewDataBinder.getRoot());
    }

    public VipFreeTipsDialog setComicDetailController(ComicDetailController controller) {
        this.viewDataBinder.setVariable(BR.comicDetailController, controller);
        return this;
    }

    public VipFreeTipsDialog setVipFreeTipsDialogViewModel(VipFreeTipsDialogViewModel viewModel) {
        this.viewDataBinder.setVariable(BR.vipFreeTipsDialogViewModel, viewModel);
        return this;
    }

    public void closeDialogOnClick(View view) {
        dismiss();
    }

}
